const { Schema, model } = require('mongoose');

const moment = require('moment');

const userSchema = new Schema({
    account: String,
    password: String,
    avatar: {type:String,default:"default.jpg"},
    balance:{type:Number,default:0},
    phone: String,
    realName: String,
    identity: String,
    idVerified: {type:Number,default:0},
    role: Number,
    frozen: Boolean,
    deleted:Boolean,
    registeredTime:{
        type: String,
        default: moment().format('YYYY年MM月DD日')
    }, //创建时间,
    customerOrders: [{
        type: Schema.Types.ObjectId, 
        ref: 'Order' 
    }],
    ownerOrders: [{
        type: Schema.Types.ObjectId,  
        ref: 'Order'  
    }],
    cars: [{
        type: Schema.Types.ObjectId,  
        ref: 'Car'  
    }],
    wishilist: [{
        type: Schema.Types.ObjectId, 
        ref: 'Car' 
    }],
}, { versionKey: false })

const User = model("User", userSchema, "user")
module.exports.User = User